package com.jiang.专题.哈希表.Q205;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/01/23 19:07
 */
class Solution {
    public boolean isIsomorphic(String s, String t) {
        Map<Character, Character> map1 = new HashMap<>();
        Map<Character, Character> map2 = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            Character c1 = s.charAt(i);
            Character c2 = t.charAt(i);
            Character c22 = map1.get(c1);
            Character c11 = map2.get(c2);
            if (c11 == null && c22 == null) {
                map1.put(c1, c2);
                map2.put(c2, c1);
            } else if (c1 != c11 || c2 != c22) {
                return false;
            }
        }
        return true;
    }
}
